﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<UncleBobWebService.Models.RegisterModel>" %>

<!DOCTYPE html>

<html>
  <head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title>Register</title>
    <link href="/Theme/UncleBobTheme.css" rel="Stylesheet" />

    <script lang="cs" runat=server>
        protected void Page_Load(Object obj, EventArgs e)
        {
            HtmlInputText username = (HtmlInputText)this.form1.FindControl("txtName");
            HtmlInputText firstname = (HtmlInputText)this.form1.FindControl("txtFirstN");           
            HtmlInputText lastname = (HtmlInputText)this.form1.FindControl("txtLastN");
            HtmlInputText middle = (HtmlInputText)this.form1.FindControl("txtMiddle");
            HtmlInputText phone = (HtmlInputText)this.form1.FindControl("txtPhone");
            HtmlInputText email = (HtmlInputText)this.form1.FindControl("txtEmail");
            HtmlInputText address = (HtmlInputText)this.form1.FindControl("txtAddress");

            username.Value = Model.Username;
            firstname.Value = Model.FirstName;
            lastname.Value = Model.LastName;
            middle.Value = Model.MI;
            phone.Value = Model.PhoneNumber;
            email.Value = Model.Email;
            address.Value = Model.Address;
        }
    </script>
  </head>

  <body class="body">
    
    <% string register = string.Empty; %>

    <% if (null == Model.Username) { %>
       <% register = "Register a New Account"; %>
    <%} %>
    <% else {%>
       <% register = "Edit Your Registration"; %>
    <%} %>

    <!-- Headers -->
    <h2><%= register %></h2>

    <form id="form1" runat="server" action="/Register/FormAction">
        <!-- User input field -->
        <div class="box">
            <div class="content">
                <div>
                    Username:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                        ErrorMessage="Username is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="text" runat="server" id="txtName" class="text" value="<%Model.Username %>" /> 
                </div>
                <br />
                <div>
                    Password:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPWord"
                        ErrorMessage="Password is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="password" runat="server" id="txtPWord" class="text"/> 
                </div>
                <br />
                <div>
                    Re-enter Password:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtRPWord"
                        ErrorMessage="Re-enter password." class="validation">
                        *
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtRPWord"
                            ControlToCompare="txtPWord" ErrorMessage="Password does not match." class="validation"> *
                        </asp:CompareValidator>
                    </asp:RequiredFieldValidator>
                    <input type="password" runat="server" id="txtRPWord" class="text"/>
                </div>
                <br />
                <div>
                    First Name:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtFirstN"
                        ErrorMessage="First name is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="text" runat="server" id="txtFirstN" class="text" value="<%Model.FirstName %>"/>
                </div>
                <br />
                <div>
                    Last Name:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtLastN"
                        ErrorMessage="Last name is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="text" runat="server" id="txtLastN" class="text" value="<%Model.LastName %>" />
                </div>
                <br />
                <div>
                    Middle Initial:
                    <asp:RegularExpressionValidator ID="RegularExpressionValidation1" runat="server"
                        ControlToValidate="txtMiddle" ErrorMessage="Middle Initial must be 1-2 character"
                        ValidationExpression="[a-zA-z]{1}" class="validation"> *
                    </asp:RegularExpressionValidator>
                    <input type="text" runat="server" id="txtMiddle" class="text"  value="<%Model.MI %>"/>
                </div>
                <br />
                <div>
                    Phone Number:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtPhone"
                        ErrorMessage="Phone Number is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="text" runat="server" id="txtPhone" class="text" value="<%Model.PhoneNumber %>"/>
                </div>
                <br />
                <div>
                    Email:
                    <asp:RegularExpressionValidator ID="RegularExpressionValidation2" runat="server"
                        ControlToValidate="txtEmail" ValidationExpression=".*[@].*" ErrorMessage="Email must contain @." class="validation"> *
                    </asp:RegularExpressionValidator>
                    <input type="text" runat="server" id="txtEmail" class="text" value="<%Model.Email %>"/>
                </div>
                <br />
                <div>
                    Address:
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtAddress"
                        ErrorMessage="Address is required." class="validation"> *
                    </asp:RequiredFieldValidator>
                    <input type="text" runat="server" id="txtAddress" class="text" value="<%Model.Address %>"/>
                </div>
            </div>
        </div>

        <!-- Buttons -->
        <div style="margin-top:30px">
            <input class=button type=submit runat=server id=cmdPreview name=preview value=Preview>
            <input class=button type=submit id=cmdCancel name=cancel value=Cancel>
        </div>

      <!-- Display validation summary -->
      <br />
      <div class="content">
          <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="There were errors on the page:"
              class="error-summary" />
      </div>
    </form>
  </body>
</html>
